package com.infinit.easyreader.adpter;

import android.content.Context;
import android.view.LayoutInflater;

import java.util.ArrayList;
import java.util.List;

/**
 * 类：BaseAdapter [V 1.0.0]
 * 包含类 : com.infinit.easyreader.adpter.BaseAdapter
 * 作用：所有需要实现BaseAdapter的类调整为继承该类
 * Created by rzy on 2016/1/30.
 */
public abstract class BaseAdapter<T> extends android.widget.BaseAdapter {
    /**
     * 数据源
     */
    private List<T> dataList;
    private Context context;
    private LayoutInflater inflater;

    public BaseAdapter(List<T> dataList, Context context) {
        this.dataList = dataList;
        this.context = context;
        inflater = LayoutInflater.from(this.context);
    }

    public LayoutInflater getInflater() {
        return inflater;
    }

    public List<T> getDataList() {
        return dataList;
    }

    public void setDataList(List<T> dataList) {
        if (dataList == null) {
            this.dataList = new ArrayList<>();
        } else {
            this.dataList = dataList;
        }
    }

    @Override
    public int getCount() {
        return dataList.size();
    }

    @Override
    public Object getItem(int position) {
        return dataList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

}
